home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / bootst11.lzh / PF BOOTSTRAP VATIPX PREMOTEC < prev    next >
Text File  |  1989-05-24  |  4KB  |  187 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  */
  17.  
  18. #ifndef lint
  19. static char sccsid[] = "@(#)remote.c    5.4 (Berkeley) 9/2/88";
  20. #endif /* not lint */
  21.  
  22. # include "tip.h"
  23.  
  24. /*
  25.  * Attributes to be gleened from remote host description
  26.  *   data base.
  27.  */
  28. static char **caps[] = {
  29.     &AT,  &DV,  &CM,  &CU,  &EL,  &IE,  &OE,  &PN,  &PR,
  30.     &DI,  &ES,  &EX,  &FO,  &RC,  &RE,  &PA,  &SA,  &DA,
  31.     &SM,  &ST,  &LS
  32. };
  33.  
  34. static char *capstrings[] = {
  35.     "at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr",
  36.     "di", "es", "ex", "fo", "rc", "re", "pa", "sa", "da",
  37.     "sm", "st", "ls", 0
  38. };
  39.  
  40. char *rgetstr();
  41.  
  42. static
  43. getremcap(host)
  44.     register char *host;
  45. {
  46.     int stat;
  47.     char tbuf[BUFSIZ];
  48.     static char buf[BUFSIZ/2];
  49.     char *bp = buf;
  50.     register char **p, ***q;
  51.  
  52.     if ((stat = rgetent(tbuf, host)) <= 0) {
  53.         if (DV ||
  54.             host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
  55.             CU = DV;
  56.             HO = host;
  57.             HW = 1;
  58.             DU = 0;
  59.             if (!BR)
  60.                 BR = DEFBR;
  61.             FS = DEFFS;
  62.             return;
  63.         }
  64.         fprintf(stderr, stat == 0 ?
  65.             "tip: unknown host %s\n" :
  66.             "tip: can't open host description file\n", host);
  67.         exit(3);
  68.     }
  69.  
  70.     for (p = capstrings, q = caps; *p != NULL; p++, q++)
  71.         if (**q == NULL)
  72.             **q = rgetstr(*p, &bp);
  73.     if (!BR && (BR = rgetnum("br")) < 0)
  74.         BR = DEFBR;
  75.     if ((FS = rgetnum("fs")) < 0)
  76.         FS = DEFFS;
  77.     if (DU < 0)
  78.         DU = 0;
  79.     else
  80.         DU = rgetflag("du");
  81.     if (DV == NOSTR) {
  82.         fprintf(stderr, "%s: missing device spec\n", host);
  83.         exit(3);
  84.     }
  85.     if (DU && CU == NOSTR)
  86.         CU = DV;
  87.     if (DU && PN == NOSTR) {
  88.         fprintf(stderr, "%s: missing phone number\n", host);
  89.         exit(3);
  90.     }
  91.  
  92.     HD = rgetflag("hd");
  93.  
  94.     /*
  95.      * This effectively eliminates the "hw" attribute
  96.      *   from the description file
  97.      */
  98.     if (!HW)
  99.         HW = (CU == NOSTR) || (DU && equal(DV, CU));
  100.     HO = host;
  101.     /*
  102.      * see if uppercase mode should be turned on initially
  103.      */
  104.     if (rgetflag("ra"))
  105.         boolean(value(RAISE)) = 1;
  106.     if (rgetflag("ec"))
  107.         boolean(value(ECHOCHECK)) = 1;
  108.     if (rgetflag("be"))
  109.         boolean(value(BEAUTIFY)) = 1;
  110.     if (rgetflag("nb"))
  111.         boolean(value(BEAUTIFY)) = 0;
  112.     if (rgetflag("sc"))
  113.         boolean(value(SCRIPT)) = 1;
  114.     if (rgetflag("tb"))
  115.         boolean(value(TABEXPAND)) = 1;
  116.     if (rgetflag("vb"))
  117.         boolean(value(VERBOSE)) = 1;
  118.     if (rgetflag("nv"))
  119.         boolean(value(VERBOSE)) = 0;
  120.     if (rgetflag("ta"))
  121.         boolean(value(TAND)) = 1;
  122.     if (rgetflag("nt"))
  123.         boolean(value(TAND)) = 0;
  124.     if (rgetflag("rw"))
  125.         boolean(value(RAWFTP)) = 1;
  126.     if (rgetflag("hd"))
  127.         boolean(value(HALFDUPLEX)) = 1;
  128.     if (rgetflag("rt"))
  129.         boolean(value(SETROUTE)) = 1;
  130.     if (rgetflag("li"))
  131.         boolean(value(LINESYNC)) = 1;
  132.     if (rgetflag("dt"))
  133.         boolean(value(DTRHUP)) =1;
  134.     if (RE == NOSTR)
  135.         RE = (char *)"tip.record";
  136.     if (EX == NOSTR)
  137.         EX = (char *)"\t\n\b\f";
  138.     if (ES != NOSTR)
  139.         vstring("es", ES);
  140.     if (FO != NOSTR)
  141.         vstring("fo", FO);
  142.     if (PR != NOSTR)
  143.         vstring("pr", PR);
  144.     if (RC != NOSTR)
  145.         vstring("rc", RC);
  146.     if ((DL = rgetnum("dl")) < 0)
  147.         DL = 0;
  148.     if ((CL = rgetnum("cl")) < 0)
  149.         CL = 0;
  150.     if ((ET = rgetnum("et")) < 0)
  151.         ET = 10;
  152. }
  153.  
  154. char *
  155. getremote(host)
  156.     char *host;
  157. {
  158.     register char *cp;
  159.     static char *next;
  160.     static int lookedup = 0;
  161.  
  162.     if (!lookedup) {
  163.         if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
  164.             fprintf(stderr, "tip: no host specified\n");
  165.             exit(3);
  166.         }
  167.         getremcap(host);
  168.         next = DV;
  169.         lookedup++;
  170.     }
  171.     /*
  172.      * We return a new device each time we're called (to allow
  173.      *   a rotary action to be simulated)
  174.      */
  175.     if (next == NOSTR)
  176.         return (NOSTR);
  177.     if ((cp = index(next, ',')) == NULL) {
  178.         DV = next;
  179.         next = NOSTR;
  180.     } else {
  181.         *cp++ = '\0';
  182.         DV = next;
  183.         next = cp;
  184.     }
  185.     return (DV);
  186. }
  187.